#include <iostream>
#include <string>
#include <vector>

using std::cout;
using std::endl;
using std::string;
using std::vector;

string ret;

void fun(string &str, int i, int len)
{
    if(i == len){
        cout << str << endl;
    }else{
        for(int j{i}; j < len; j++){
            char tmp = str[i];
            str[i] = str[j];
            str[j] = tmp;
            fun(str, i + 1, len);
            str[j] = str[i];
            str[i] = tmp;
        }
    }

}

int main(int args, char *argv[])
{
    string str = "hello";
    fun(str, 0, str.length());
    return 0;
}